# Question 1
palo <- readr::read_csv("data/uscities.csv") %>%
st_as_sf(coords = c("lng", "lat"), crs = 4326) %>%
filter(city == "Palo", state_name == "Iowa") %>%
st_transform(5070)
palo_bbox <- palo %>%
st_buffer(5000) %>%
st_bbox() %>%
st_as_sfc() %>%
st_as_sf()
# Question 2.2
palo_scene <- readr::read_csv("data/palo-flood-scene.csv")[1,]$download_url %>%
lsat_scene_files()
palo_scene_urls <- palo_scene %>%
filter(grepl(paste0('B', 1:6, ".TIF$", collapse = "|"), palo_scene$file)) %>%
arrange(file) %>%
pull(file)
# Question 2.3
#st <- sapply(palo_scene_urls, lsat_image)
# lsat_image() was not working for me due to a partition error in my HDD, which gave me the error
# "Invalid cross-device link" when file.rename() was called. So, I worked around this by manually
# downloading the *.TIF files via wget into the .cache/landsat-pds/... folder. This results in
# the cache still seeing the *.TIF files:
st <- lsat_cache_list()
bands <- stack(st) %>%
setNames(paste0("band", 1:6))
bands_crop <- bands %>%
crop(st_transform(palo_bbox,"+proj=utm +zone=15 +datum=WGS84 +units=m +no_defs"))
bands_crop <- setNames(bands_crop, c("Coastal", "Blue", "Green", "Red", "NIR", "SWIR 1"))
The attributes of our stacked bands are given as,
+proj=utm +zone=15 +datum=WGS84 +units=m +no_defsThe attributes of our cropped bands are given as,
+proj=utm +zone=15 +datum=WGS84 +units=m +no_defsStretching in this case is a way of increasing clarity by normalizing the distribution of brightness across a raster. In general, these diagrams from NeonScience display the general concept behind stretching:
When stretching, there are two methods: Linear or Histogram. Linear is the method shown in the diagrams above, where points are taken and linearly scaled. Histogram stretching occurs conceptually by stretching the ends of the intesity (brightness/contrast) of a raster: